<template>
  <div class="moneyDetail">
    <div class="bt_box">
      <p class="btText">门店管理员账号</p>
    </div>
    <div class="information">
      <div class="list" style="with: 100%">
        <div class="lable"><span class="import">*</span>门店管理员账号:</div>
        <el-input
          v-model="fromBase.account"
          placeholder="请输入门店管理员账号"
          style="width: 202px"
          maxlength="11"
        ></el-input>
      </div>
      <!-- <div class="list" style="with: 100%">
        <div class="lable">
          <span class="import">*</span>发连锁通用卡存管比例:
        </div>
        <el-input
          v-model="fromBase.ratio"
          placeholder="请输入存管比例"
          style="width: 202px"
        >
          <template slot="append">%</template>
        </el-input>
      </div> -->
    </div>
    <div class="bt_box">
      <p class="btText">客户基本资料</p>
    </div>
    <div class="information">
      <div class="list">
        <div class="lable"><span class="import">*</span>企业名称:</div>
        <div>
          <el-input
            v-model="fromBase.businessLicence"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>统一社会信用代码:</div>
        <div>
          <el-input
            v-model="fromBase.businessLicenceNo"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable">客户类型:</div>
        <div class="txt">
          <el-select v-model="fromBase.merchantType" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.value"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>店铺名称:</div>
        <div>
          <el-input
            v-model="fromBase.userShortName"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>企业成立日期:</div>
        <div>
          <el-date-picker
            v-model="fromBase.businessLicenceSdate"
            type="date"
            placeholder="选择日期"
            format="yyyy.MM.dd"
            value-format="yyyy.MM.dd"
            :clearable="false"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>经营期限:</div>
        <div>
          <el-radio-group v-model="radio" @change="changeRadio">
            <el-radio :label="1">
              <el-date-picker
                v-model="qxDate"
                type="date"
                placeholder="选择日期"
                format="yyyy.MM.dd"
                value-format="yyyy.MM.dd"
                :clearable="false"
                :disabled="pickDisabled"
                @change="changeDate"
              >
              </el-date-picker>
            </el-radio>
            <el-radio :label="2" style="margin-top: 10px">长期</el-radio>
          </el-radio-group>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人姓名:</div>
        <div>
          <el-input
            v-model="fromBase.legalPersonName"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人证件类型:</div>
        <div class="text">身份证</div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人身份证号:</div>
        <div>
          <el-input
            v-model="fromBase.legalPersonId"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>

      <div class="list">
        <div class="lable">
          <span class="import">*</span>法人身份证开始日期:
        </div>
        <div>
          <el-date-picker
            v-model="fromBase.legalPersonIdSdate"
            type="date"
            placeholder="选择日期"
            format="yyyy.MM.dd"
            value-format="yyyy.MM.dd"
            :clearable="false"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable">
          <span class="import">*</span>法人身份证结束日期:
        </div>
        <div>
          <el-date-picker
            v-model="fromBase.legalPersonIdEdate"
            type="date"
            placeholder="选择日期"
            format="yyyy.MM.dd"
            value-format="yyyy.MM.dd"
            :clearable="false"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人联系电话:</div>
        <div>
          <el-input v-model="fromBase.phone" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>注册地址:</div>
        <div>
          <el-input
            v-model="fromBase.registeredAddress"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>店铺类型:</div>
        <div>
          <el-cascader
            v-model="avalue"
            :options="typeLs"
            :show-all-levels="false"
            @change="handleChange"
          ></el-cascader>
        </div>
      </div>
    </div>
    <div class="bt_box">
      <p class="btText">结算账户资料</p>
    </div>
    <div class="information">
      <div class="list">
        <div class="lable"><span class="import">*</span>结算方式:</div>
        <div class="txt">
          <el-select
            v-model="fromBase.settleBankType"
            placeholder="请选择"
            @change="changeBankType"
          >
            <el-option
              v-for="item in options2"
              :key="item.id"
              :label="item.value"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>结算费率:</div>
        <div>
          <el-input v-model="fromBase.balanceAccRate" placeholder="请输入"
            ><template slot="append">%</template></el-input
          >
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>结算类型:</div>
        <div class="txt">
          <el-select v-model="fromBase.clearingType" placeholder="请选择">
            <el-option
              v-for="item in options3"
              :key="item.id"
              :label="item.value"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable"><span class="import">*</span>法人姓名:</div>
        <div>
          <el-input
            v-model="fromBase.legalPersonName"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable"><span class="import">*</span>非法人姓名:</div>
        <div>
          <el-input
            v-model="fromBase.unincorporatedName"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable"><span class="import">*</span>法人身份证号:</div>
        <div>
          <el-input
            v-model="fromBase.legalPersonId"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable"><span class="import">*</span>非法人身份证号:</div>
        <div>
          <el-input
            v-model="fromBase.unincorporatedId"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable">
          <span class="import">*</span>法人身份证开始日期:
        </div>
        <div>
          <el-date-picker
            v-model="fromBase.legalPersonIdSdate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          <span class="import">*</span>非法人身份证开始日期:
        </div>
        <div>
          <el-date-picker
            v-model="fromBase.unincorporatedIdSdate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable">
          <span class="import">*</span>法人身份证结束日期:
        </div>
        <div>
          <el-date-picker
            v-model="fromBase.legalPersonIdEdate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          <span class="import">*</span>非法人身份证结束日期:
        </div>
        <div>
          <el-date-picker
            v-model="fromBase.unincorporatedIdEdate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>结算银行卡号:</div>
        <div>
          <el-input
            v-model="fromBase.balanceAccCardno"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>开户行名称:</div>
        <div class="txt">
          <el-select
            v-model="fromBase.bankName"
            placeholder="请选择"
            @change="changes"
          >
            <el-option
              v-for="item in bankOptionone"
              :key="item.id"
              :label="item.label"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>所属支行名称:</div>
        <div class="txt">
          <el-select
            v-model="fromBase.openAccBankname"
            placeholder="请选择"
            @change="changesTwo"
          >
            <el-option
              v-for="item in bankOptiontwo"
              :key="item.id"
              :label="item.label"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>银行预留手机号:</div>
        <div>
          <el-input
            v-model="fromBase.bankMobile"
            placeholder="请输入"
          ></el-input>
        </div>
      </div>
    </div>
    <div class="bt_box">
      <p class="btText">资质图片</p>
    </div>
    <div class="imgBox" v-loading="allLoading" element-loading-text="上传中">
      <div class="imgList">
        <div class="lable">
          营业执照:
          <p
            class="watch_img"
            @click="handleFang(fromImg.businessLicenceImg)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(1, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.businessLicenceImg"
            :src="fromImg.businessLicenceImg"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 1">
        <div class="lable">
          开户许可证:
          <p class="watch_img" @click="handleFang(fromImg.licence)">
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(2, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.licence"
            :src="fromImg.licence"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          法人身份证正面:
          <p
            class="watch_img"
            @click="handleFang(fromImg.legalPersonFront)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(3, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.legalPersonFront"
            :src="fromImg.legalPersonFront"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          法人身份证反面:
          <p
            class="watch_img"
            @click="handleFang(fromImg.legalPersonBack)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(4, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.legalPersonBack"
            :src="fromImg.legalPersonBack"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          门头照:
          <p class="watch_img" @click="handleFang(fromImg.shopTop)">
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(5, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.shopTop"
            :src="fromImg.shopTop"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          室内场景照:
          <p
            class="watch_img"
            @click="handleFang(fromImg.shopInterior)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(6, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.shopInterior"
            :src="fromImg.shopInterior"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          收银台照:
          <p
            class="watch_img"
            @click="handleFang(fromImg.shopCashierDesk)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(7, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.shopCashierDesk"
            :src="fromImg.shopCashierDesk"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType != 1">
        <div class="lable">
          结算银行卡正面:
          <p
            class="watch_img"
            @click="handleFang(fromImg.bankCardFront)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(8, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.bankCardFront"
            :src="fromImg.bankCardFront"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType != 1">
        <div class="lable">
          结算银行卡反面:
          <p
            class="watch_img"
            @click="handleFang(fromImg.bankCardBack)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(9, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.bankCardBack"
            :src="fromImg.bankCardBack"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          非法人身份证正面:
          <p
            class="watch_img"
            @click="handleFang(fromImg.unLegalPersonFront)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(10, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.unLegalPersonFront"
            :src="fromImg.unLegalPersonFront"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          非法人身份证反面:
          <p
            class="watch_img"
            @click="handleFang(fromImg.unLegalPersonBack)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(11, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.unLegalPersonBack"
            :src="fromImg.unLegalPersonBack"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          法人持授权书正面照:
          <p
            class="watch_img"
            @click="handleFang(fromImg.handAuthorization)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(12, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.handAuthorization"
            :src="fromImg.handAuthorization"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <!-- <div class="imgList">
        <div class="lable">
          法人手持身份证合照:
          <p
            class="watch_img"
            @click="handleFang(fromBase.handIdCard)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(13, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromBase.handIdCard"
            :src="fromBase.handIdCard"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div> -->
      <div class="imgList" v-if="fromBase.settleBankType == 1">
        <div class="lable">
          面签二联单合同:
          <p class="watch_img" @click="handleFang(fromImg.contract)">
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(14, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromImg.contract"
            :src="fromImg.contract"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
    </div>
    <img-detail-dialog
      v-if="ImgDetailDialog"
      :id="id"
      :imgUrl="urlData"
      :visible.sync="ImgDetailDialog"
    />
    <div class="button_box">
      <el-button
        style="margin: 0 10px 0 20px"
        @click="setYspush(1)"
        type="primary"
        :loading="buttomLoading"
        >推送银盛开户</el-button
      >
      <el-button style="margin: 0 10px 0 20px" @click="setYspush(2)"
        >提交门店申请</el-button
      >
    </div>
  </div>
</template>
<script>
// components
import Loading from "@/components/Loading/index";
import imgDetailDialog from "./components/imgDetailDialog";

//api
import {
  adminDict,
  getBank,
  addMerchant,
  getmerchantDetail,
  updateMerchant,
  saveMerchantShop,
  watermarkUploadFile,
} from "@/api/chainManagement";
import { shopTypeTree } from "@/api/merchants";
// import { List } from "echarts/lib/export";

export default {
  components: {
    Loading,
    imgDetailDialog,
  },
  props: {
    visible: Boolean,
    id: String,
  },
  data() {
    return {
      dialogFormVisible: false,
      formLabelWidth: "130px",
      merchantId: "",
      allLoading: false,
      buttomLoading: false,
      buttomLoading2: false,
      action: process.env.VUE_APP_BASE_API + "/common/v1/uploadFile",
      detailDialog: false,
      data: {},
      ImgDetailDialog: false,
      options: [],
      options2: [],
      options3: [],
      value: "",
      input: "",
      typeLs: [],
      avalue: [],
      radio: 2, //经营期限选择
      pickDisabled: true, //是否禁用经营期限时间选择
      qxDate: "",
      ysimgurl: "", //二联单合同图片路径
      fromBase: {
        chainId: "", //总店id
        account: "", //管理员帐号
        businessLicence: "", //企业名称
        businessLicenceNo: "", //营业执照号码
        userShortName: "", //店铺名称
        merchantType: "1", //连锁商家类型 1 企业商家 2 个体商家
        businessLicenceSdate: "", //营业执照开始日期
        businessLicenceEdate: "长期", //营业执照结束日期
        legalPersonName: "", //法人姓名
        legalPersonId: "", //法人身份证号
        legalPersonIdSdate: "", //法人身份证开始日期
        legalPersonIdEdate: "", //法人身份证到期日期
        phone: "", //法人联系电话
        registeredAddress: "", //注册地址
        settleBankType: "1", //结算方式
        unincorporatedName: "", //非法人姓名
        unincorporatedId: "", //非法人身份证号码
        unincorporatedIdSdate: "", //非法人身份证开始日期
        unincorporatedIdEdate: "", //非法人身份证到期日期
        balanceAccCardno: "", //结算账户卡号
        balanceAccRate: "0.3", //结算账户费率
        bankName: "", //开户行名称
        openAccBankname: "", //开户支行名称
        bankMobile: "", //银行预留手机号
        certType: "00", //证件类型 00 身份证
        // businessLicenceImg: "", //营业执照图片
        // legalPersonFront: "", //法人身份证正面
        // legalPersonBack: "", //法人身份证反面
        // bankCardFront: "", //结算银行卡正面
        // bankCardBack: "", //结算银行卡反面
        // shopTop: "", //商户门头照片
        // shopInterior: "", //内景照片
        // shopCashierDesk: "", //收银台照片
        // handIdCard: "", //手持身份证合影照片
        // contract: "", //二联单合同
        // licence: "", //开户许可证
        // handAuthorization: "", //法人/非法人手持授权书
        // settleAuthorization: "", //法人/非法人结算授权书
        // unLegalPersonFront: "", //非法人身份证正面
        // unLegalPersonBack: "", //非法人身份证反面
        saveType: "", //保存类型  1 推送银盛 2 直接新增
        shopTypeParent: "", //店铺父类型
        shopTypeName: "", //店铺类型子类型名称
        // watermarkBusinessLicenseImg: "", //营业执照图片(水印营业执照)
      },
      fromImg: {
        watermarkBusinessLicenseImg: "", //营业执照图片(水印营业执照)
        businessLicenceImg: "", //营业执照图片
        legalPersonFront: "", //法人身份证正面
        legalPersonBack: "", //法人身份证反面
        bankCardFront: "", //结算银行卡正面
        bankCardBack: "", //结算银行卡反面
        shopTop: "", //商户门头照片
        shopInterior: "", //内景照片
        shopCashierDesk: "", //收银台照片
        handIdCard: "", //手持身份证合影照片
        contract: "", //二联单合同
        licence: "", //开户许可证
        handAuthorization: "", //法人/非法人手持授权书
        settleAuthorization: "", //法人/非法人结算授权书
        unLegalPersonFront: "", //非法人身份证正面
        unLegalPersonBack: "", //非法人身份证反面
      },
      bankOptionone: [], //银行
      bankOptiontwo: [], //支行
      info: {},
      status: 1, //区分推送接口
    };
  },
  computed: {},
  created() {
    this.fromBase.chainId = this.$route.query.chainId;
    this.getTypels();
    this.getlinkagelist();
    this.getbankType();
    this.getclearingType();
    this.getBank();
    // if (this.merchantId != 0 && this.info.account == undefined) {
    //   this.status = 2;
    //   this.getDetail();
    // }
  },
  methods: {
    getlinkagelist() {
      //获取商户类型字典
      const params = {
        dictType: "merchant_type",
      };
      adminDict(params).then((res) => {
        this.options = res.result[0].dictList;
      });
    },
    getclearingType() {
      //获取结算类型字典
      const params = {
        dictType: "merchant_clearing_type",
      };
      adminDict(params).then((res) => {
        this.options3 = res.result[0].dictList;
      });
    },
    // 获取店铺类型
    getTypels() {
      //shopTypeTree
      this.loading = true;
      shopTypeTree()
        .then((res) => {
          let ls = [];
          console.log("res.result+++", res.result);
          ls = this.getTreeData(res.result);
          // console.log(this.typeLs)
          let ls1 = ls.map((item) => {
            item.value = item.id;
            item.children.map((items) => {
              items.value = items.id;
            });
            return item;
          });
          console.log("ls1+++", ls1);
          this.typeLs = ls1;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    handleChange(value) {
      //店铺类型选择
      let _this = this;
      console.log("value+++++++++++++", value[1], value);
      let list = this.typeLs.filter((item) => {
        if (item.id == value[0]) {
          return item;
        }
      });
      let listChild = list[0].children.filter((item) => {
        if (item.id == value[1]) {
          return item;
        }
      });
      _this.fromBase.shopTypeParent = value[0];
      _this.fromBase.shopType = value[1];
      _this.fromBase.shopTypeName = listChild[0].label;
      console.log(
        "****",
        _this.fromBase.shopTypeParent,
        _this.fromBase.shopType,
        _this.fromBase.shopTypeName
      );
    },
    getTreeData(data) {
      // 循环遍历json数据
      for (var i = 0; i < data.length; i++) {
        if (data[i].children.length < 1) {
          // children若为空数组，则将children设为undefined
          // data[i].children=undefined;
          delete data[i].children;
        } else {
          // children若不为空数组，则继续 递归调用 本方法
          this.getTreeData(data[i].children);
        }
      }
      return data;
    },
    changeRadio(e) {
      //经营期限选择
      console.log(e);
      if (e == 2) {
        this.pickDisabled = true;
        this.fromBase.businessLicenceEdate = "长期";
      } else {
        this.pickDisabled = false;
        this.fromBase.businessLicenceEdate = this.qxDate;
      }
    },
    changeDate(e) {
      //经营期限日期选择
      console.log(e);
      this.fromBase.businessLicenceEdate = e;
    },
    //获取进件商户基础信息
    getDetail() {
      const id = this.merchantId;
      getmerchantDetail(id)
        .then((res) => {
          if (res.result.businessLicenceEdate == "长期") {
            this.fromBase.businessLicenceEdate = "长期";
            this.radio = 2;
            this.pickDisabled = true;
          } else {
            this.qxDate = res.result.businessLicenceEdate;
            this.pickDisabled = false;
            this.radio = 1;
            this.fromBase.businessLicenceEdate = this.qxDate;
          }
          this.fromBase = res.result;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    getbankType() {
      //获取结算方式字典
      const params = {
        dictType: "manage_settle_bank_type",
      };
      adminDict(params).then((res) => {
        this.options2 = res.result[0].dictList;
      });
    },
    changeBankType(e) {
      //结算方式选择
      if (e == 3) {
        this.fromBase.legalPersonName = "";
        this.fromBase.legalPersonId = "";
        this.fromBase.legalPersonIdSdate = "";
        this.fromBase.legalPersonIdEdate = "";
      } else {
        this.fromBase.unincorporatedName = "";
        this.fromBase.unincorporatedId = "";
        this.fromBase.unincorporatedIdSdate = "";
        this.fromBase.unincorporatedIdEdate = "";
      }
    },
    getBank() {
      //获取银行信息
      const params = {};
      getBank(params).then((res) => {
        console.log(res.result);
        this.bankOptionone = res.result;
        // if (this.fromSettle.bankType != "") {
        this.bankOptionone.map((item, index) => {
          // if (this.fromSettle.bankType == item.id) {
          //   console.log(1111);
          //   this.bankOptiontwo = item.children;
          // }
          this.bankOptiontwo = item.children;
        });
        // }
        console.log(this.bankOptiontwo);
      });
    },
    changes(value) {
      //银行
      console.log(value);
      this.bankOptionone.map((item, index) => {
        if (value == item.id) {
          this.bankOptiontwo = item.children;
          this.fromBase.bankName = item.label;
        }
      });
    },
    changesTwo(id) {
      //支行选择
      this.bankOptiontwo.map((item, index) => {
        if (id == item.id) {
          // this.fromSettle.openAccBanktype = item.id;
          this.fromBase.openAccBankname = item.label;
        }
      });
    },
    handlePreview(e) {
      console.log(e);
      this.allLoading = true;
      setTimeout(() => {
        this.allLoading = false;
      }, 10000);
    },
    handleAvatarSuccess(e, res, file) {
      this.allLoading = false;
      //上传资质图片
      //   this.formInline.shopIcon = res.result.url;
      console.log("++++", e);
      console.log("file", file);
      console.log(res.result);
      // this.fromBase.id = this.ysimgInfo.id;
      if (e == 1) {
        this.fromImg.businessLicenceImg = res.result.url;
        console.log("fileraw", file.raw);
        let params = new FormData();
        params.append("file", file.raw); // 文件对象
        watermarkUploadFile(params)
          .then((res) => {
            this.fromImg.watermarkBusinessLicenseImg = res.result.url;
          })
          .finally(() => {});
      } else if (e == 2) {
        this.fromImg.licence = res.result.url;
      } else if (e == 3) {
        this.fromImg.legalPersonFront = res.result.url;
      } else if (e == 4) {
        this.fromImg.legalPersonBack = res.result.url;
      } else if (e == 5) {
        this.fromImg.shopTop = res.result.url;
      } else if (e == 6) {
        this.fromImg.shopInterior = res.result.url;
      } else if (e == 7) {
        this.fromImg.shopCashierDesk = res.result.url;
      } else if (e == 8) {
        this.fromImg.bankCardFront = res.result.url;
      } else if (e == 9) {
        this.fromImg.bankCardBack = res.result.url;
      } else if (e == 10) {
        this.fromImg.unLegalPersonFront = res.result.url;
      } else if (e == 11) {
        this.fromImg.unLegalPersonBack = res.result.url;
      } else if (e == 12) {
        this.fromImg.handAuthorization = res.result.url;
      } else if (e == 13) {
        this.fromImg.handIdCard = res.result.url;
      } else if (e == 14) {
        this.fromImg.contract = res.result.url;
      }
      console.log(this.fromImg.businessLicenceImg);
      //   console.log("fileraw", file.raw);
      //   let params = new FormData();
      //   params.append("file", file.raw); // 文件对象
      //   watermarkUploadFile(params)
      //     .then((res) => {
      //       console.log(res);
      //     })
      //     .finally(() => {});
    },
    //放大图片
    handleFang(url) {
      this.urlData = url;
      this.ImgDetailDialog = true;
    },
    onExceed(files, fileList) {
      this.$message.error("最多上传1张图片");
    },
    httpRequest(val) {
      console.log(val.file);
      let params = new FormData();
      params.append("file", val.file); // 文件对象
      //   const params = {
      //     file: val.file,
      //   };
      console.log(params);
      watermarkUploadFile(params)
        // this.buttomLoading = true
        .then((res) => {
          console.log(res);
        })
        .finally(() => {});
    },
    beforeAvatarUpload(file) {
      console.log("file", file);
      const format = ["image/jpeg", "image/jpg", "image/png"];
      const isJPG = format.some((item) => file.type === item);
      // const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isJPG) {
        this.$message.error("上传图片只能是 jpeg,jpg,png格式!");
      }
      //   if (!isLt2M) {
      //     this.$message.error("上传头像图片大小不能超过 2MB!");
      //   }
      // return isJPG && isLt2M;
      return isJPG;
    },
    getPush() {
      this.fromBase.account = this.fromBase.account.replace(
        /(^\s*)|(\s*$)/g,
        ""
      );
      if (this.status == 1) {
        this.setYspush();
      } else {
        this.updateMerchant();
      }
    },
    setYspush(e) {
      //推送银盛审核
      //   return;
      this.fromBase.account = this.fromBase.account.replace(
        /(^\s*)|(\s*$)/g,
        ""
      );
      this.fromBase.saveType = e;
      var formBase = {};
      if (
        this.fromBase.settleBankType == 1 ||
        this.fromBase.settleBankType == 2
      ) {
        let {
          unincorporatedName,
          unincorporatedId,
          unincorporatedIdEdate,
          unincorporatedIdSdate,
          ...newObject
        } = this.fromBase;
        formBase = newObject;
      } else {
        let {
          legalPersonName,
          legalPersonId,
          legalPersonIdSdate,
          legalPersonIdEdate,
          ...objects
        } = this.fromBase;
        formBase = objects;
      }
      var arr;
      if (
        (arr = Object.keys(formBase).filter((v) => !formBase[v])).length <= 0
      ) {
        //全部有值
        console.log("有值");
        // this.fromBase.saveType = e;
        this.buttomLoading = true;
        const params = {
          ...this.fromBase,
          ...this.fromImg,
        };
        saveMerchantShop(params)
          // this.buttomLoading = true
          .then((res) => {
            this.$message({
              message: "新增成功",
              type: "success",
              duration: 1500,
            });
            this.buttomLoading = false;
            setTimeout(() => {
              this.$router.push({
                path: "/merchants/store-maintenance",
                query: { id: res.result },
              });
            }, 800);
          })
          .finally(() => {
            this.buttomLoading = false;
            this.buttomLoading2 = false;
          });
      } else {
        console.log(arr); //[status,other]
        console.log("没有值");
        this.$message({
          message: "请完善信息",
          type: "warning",
          duration: 1500,
        });
      }

      // this.fromBase.saveType = e;
      // this.buttomLoading = true;
      // const params = {
      //   ...this.fromBase,
      // };
      // saveMerchantShop(params)
      //   // this.buttomLoading = true
      //   .then((res) => {
      //     this.$message({
      //       message: "新增成功",
      //       type: "success",
      //       duration: 1500,
      //     });
      //     this.buttomLoading = false;
      //     setTimeout(() => {
      //       this.$router.push({
      //         path: "/merchants/store-maintenance",
      //         query: { id: res.result },
      //       });
      //     }, 800);
      //   })
      //   .finally(() => {
      //     this.buttomLoading = false;
      //     this.buttomLoading2 = false;
      //   });
    },
    updateMerchant() {
      //更新信息
      this.buttomLoading = true;
      const params = {
        id: this.merchantId,
        ...this.fromBase,
      };
      updateMerchant(params)
        .then((res) => {
          this.$message({
            message: "更新成功",
            type: "success",
            duration: 1500,
          });
          this.buttomLoading = false;
          setTimeout(() => {
            this.$router.push({
              path: "/merchants/store-maintenance",
              query: { id: res.result },
            });
          }, 800);
        })
        .finally(() => {
          this.buttomLoading = false;
        });
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./style/chainCustomersAdd";
::v-deep.el-input--medium .el-input__inner {
  width: 202px !important;
}
.import {
  color: #ff4949;
}
</style>
